<?php
class completeForm extends Form
{
    function completeForm()
    {
        Form::Form('completeForm');
    }

    function draw()
    {
        global $display;
        if (!User::is_login()) {
            return;
        }
        $order_id = Url::get('order_id');
        if ($order_id !== 0 && isset($_SESSION['cart']) && isset($_SESSION['cart']['order_id']) && $order_id == $_SESSION['cart']['order_id']) {
            $type = Url::get('type', 0);
            if(!$type){
                Db_Booking::send_mail_order($order_id);
            }else{
                Db_DealBooking::send_mail_order($order_id);
            }
            $order_code = $_SESSION['cart']['code'];
            unset($_SESSION['cart']);
            Url::redirect('payment', array('cmd' => 'success', 'payment' => 'cash', 'order_id' => $order_id, 'order_code' => $order_code));
            return;
        } else {
            $err = 'Có lỗi xảy ra khi xử lý đơn hàng.';
            $display->add('error', $err);
            $display->output('error');
            return;
        }
    }
}
